<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>课程信息系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="app1.css">
    <script src="assets/js/echarts.min.js"></script>
    <style type="text/css">
        #search_box .search_input{
            width:40%;
            height:40px;
            border-radius:5px;
            padding:0 10px;
            float:left;
            margin-left: 27%;
            font-size:18px;
            font-family:"microsoft yahei",Arial,Helvetica,sans-serif;
        }
        #search_box .search_btn  {
            width:80px;
            height:40px;
            float:right;
            cursor: pointer;
            margin-bottom: 2%;
        }
        /*input.searchText{
            color:#aaa;
        }*/
        .glyphicon {
            font-size: 25px;
            position: relative;
            top: 9px;
            left: 47px;
            margin-left: -75px;
            display: inline-block;
            font-family: 'Glyphicons Halflings';
            font-style: normal;
            font-weight: 400;
            line-height: 1;
            /*-webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;*/
        }
        .cursor{
            cursor:pointer;
        }
        .logo-pos{
            margin-left: 36%;
            margin-top: 5%;
            margin-bottom: 2%;
            width: 20%
        }

    </style>
</head>

<body data-type="index">
    <div class="tpl-page-container tpl-page-header-fixed" style="margin-top: -20px">
        <div><a href="login.html" style="float: right;">登录</a></div>
        <div>
            <img src="assets/img/logo.png" class="logo-pos" alt="">
        </div>

        <div id="search_box">
            
                <input type="text" value="" tabindex="0" placeholder="搜索课程" class="search_input"   id = "text"/>
                    <a onclick="search_name()"><i class="glyphicon cursor am-icon-search" id="search_bars"></i></a>
                   
            <br />
            <br />  
        </div>

        <div class="tpl-content-wrapper" style="padding-top: 2%">

            <!--<div class="am-u-md-6 am-u-sm-12 row-mb index-2" style="margin-left: 245px">-->

            <div class="am-u-md-6 am-u-sm-12 row-mb index-2" style="margin-left: 8%">
                <div class="tpl-portlet" style="height: 480px">
                    <div class="tpl-portlet-title">
                        <div class="tpl-caption font-green ">
                            <i class="am-icon-cloud-download"></i>
                            <span> 用户学历占比</span>
                        </div>
                    </div>
                    <!--此部分数据请在 js文件夹下中的 app.js 中的 “百度图表A” 处修改数据 插件使用的是 百度echarts-->
                    <div class="tpl-echarts" id="tpl-echarts-A" style="position:relative;">
                    </div>
                </div>
            </div>
            <div class="am-u-md-6 am-u-sm-12 row-mb index-2" >
                <div class="tpl-portlet" style="height: 480px">
                    <div class="tpl-portlet-title">
                        <div class="tpl-caption font-green ">
                            <i class="am-icon-cloud-download"></i>
                            <span> 课程类别占比</span>
                        </div>
                    </div>
                    <!--此部分数据请在 js文件夹下中的 app.js 中的 “百度图表A” 处修改数据 插件使用的是 百度echarts-->
                    <div class="tpl-echarts" id="tpl-echarts-B">
                    </div>
                </div>
            </div>
            <!--<div class="am-u-md-6 am-u-sm-12 row-mb index-2" style="margin-left: 245px">-->
            <div class="am-u-md-6 am-u-sm-12 row-mb index-2" style="margin-left: 8%">
                <div class="tpl-portlet" style="height: 480px">
                    <div class="tpl-portlet-title">
                        <div class="tpl-caption font-green ">
                            <i class="am-icon-cloud-download"></i>
                            <span> 观看专题占比</span>
                        </div>
                    </div>
                    <!--此部分数据请在 js文件夹下中的 app.js 中的 “百度图表A” 处修改数据 插件使用的是 百度echarts-->
                    <div class="tpl-echarts" id="tpl-echarts-C">
                    </div>
                </div>
            </div>
            <div class="am-u-md-6 am-u-sm-12 row-mb index-2">
                    <div class="tpl-portlet" style="height: 480px">
                        <div class="tpl-portlet-title">
                            <div class="tpl-caption font-green ">
                                <i class="am-icon-cloud-download"></i>
                                <span> 观看演讲占比</span>
                            </div>
                        </div>
                        <!--此部分数据请在 js文件夹下中的 app.js 中的 “百度图表A” 处修改数据 插件使用的是 百度echarts-->
                        <div class="tpl-echarts" id="tpl-echarts-D">
                        </div>
                    </div>
            </div>
        </div>
    </div>
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/amazeui.min.js"></script>
        <!-- <script src="assets/js/app.js"></script> -->
        <script>
        $.ajax({
            type: "get",
            contentType: "application/json",
            url: "/count/educateNumber",
            success: function(data) {
                //data=data;
                var echartsA = echarts.init(document.getElementById('tpl-echarts-A'));
                //console.log(data.data.中学); 
                //console.log(data.data); 
                option = {
                    title: {
                        text: '用户学历占比',
                        subtext: 'mooc',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            mark: { show: true },
                            dataView: { show: true, readOnly: false },
                            magicType: {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            }

                        }
                    },
                    calculable: true,
                    series: [{
                        name: '数据详情',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: [
                            { value: data.data.中学, name: '中学' },
                            { value: data.data.专科, name: '专科' },
                            { value: data.data.本科, name: '本科' },
                            { value: data.data.硕士, name: '硕士' },
                            { value: data.data.博士, name: '博士' },
                            { value: data.data.其他, name: '其他' }
                        ]
                    }]
                };
                echartsA.setOption(option);
            }
        })
        //课程占比
        $.ajax({
            type: "get",
            contentType: "application/json",
            url: "/count/classNumber",
            success: function(data) {
                //data=data;
                var echartsB = echarts.init(document.getElementById('tpl-echarts-B'));
                //console.log(data.data.中学); 
                //console.log(data.data); 
                var da = data.data;
                var da2 = [];
                $.each(da, function(i, item) {
                    var event = {
                        value: item,
                        name: i
                    }
                    da2.push(event);
                })
                console.log(da2);
                option = {
                    title: {
                        text: '课程类别占比',
                        subtext: 'mooc',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                   
                    toolbox: {
                        show: true,
                        feature: {
                            mark: { show: true },
                            dataView: { show: true, readOnly: false },
                            magicType: {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            }

                        }
                    },
                    calculable: true,
                    series: [{
                        name: '数据详情',
                        type: 'pie',
                        radius: '50%',
                        center: ['50%', '50%'],
                        data: da2
                    }]
                };
                echartsB.setOption(option);
            }
        })
        //专题占比
        var content1=[
            [1,5],[5,10],[10,50],[50,100],[100,250]
        ];
        $.ajax({
            type: "post",
            contentType: "application/json",

            url: "/count/topicNumberOfPeople",
            data:JSON.stringify({"array":content1}),
            success: function(data) {
                //data=data;
                var echartsC = echarts.init(document.getElementById('tpl-echarts-C'));
                //console.log(data.data.中学); 
                //console.log(data.data); 
                var da2=[];
                $.each(data.data, function(i, item) {
                    var event = {
                        value: item,
                        name: content1[i]
                    }
                    da2.push(event);
                })
                console.log(da2);
                option = {
                    title: {
                        text: '观看专题数占比',
                        subtext: 'mooc',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    
                    toolbox: {
                        show: true,
                        feature: {
                            mark: { show: true },
                            dataView: { show: true, readOnly: false },
                            magicType: {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            }

                        }
                    },
                    calculable: true,
                    series: [{
                        name: '数据详情',
                        type: 'pie',
                        radius: '50%',
                        center: ['50%', '50%'],
                        data: da2
                    }]
                };
                echartsC.setOption(option);
            }
        })

        //演讲
        var content2=[
            [1,5],[5,10],[10,50],[50,100],[100,250]
        ];
        //console.log(content2)
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "/count/lectureNumberOfPeople",
            data:JSON.stringify({"array":content2}),
            success: function(data) {
                //data=data;
                var echartsD = echarts.init(document.getElementById('tpl-echarts-D'));
                //console.log(data.data.中学); 
                //console.log(data.data); 
               
                var da2 = [];
                $.each(data.data, function(i, item) {
                    var event = {
                        value: item,
                        name: content2[i]
                    }
                    da2.push(event);
                })
                console.log(da2);
                option = {
                    title: {
                        text: '观看演讲数占比',
                        subtext: 'mooc',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                   
                    toolbox: {
                        show: true,
                        feature: {
                            mark: { show: true },
                            dataView: { show: true, readOnly: false },
                            magicType: {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            }

                        }
                    },
                    calculable: true,
                    series: [{
                        name: '数据详情',
                        type: 'pie',
                        radius: '50%',
                        center: ['50%', '50%'],
                        data: da2
                    }]
                };
                echartsD.setOption(option);
            }
        })

        function search_name(){
            var course_name=$("#text").val();
            document.cookie = "keyword=" + course_name;
            window.location.href="/course_search.html?name="+course_name;
        }
       

        </script>
</body>

</html>